/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import b4.advancedgui.menu.AccordionItem;
import b4.advancedgui.menu.AccordionLeafItem;
import b4.advancedgui.menu.AccordionMenu;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import main.Office;
import main.ServicesList;
import model.system.SystemGroupAccess;
import model.system.SystemMenu;
import model.system.SystemUser;
import utility.com.GradientPanel;
import view.inventory.*;
import view.promo.PromoListFrm;
import view.publics.SupplierListFrm;
import view.purchasing.OrderListFrm;
import view.sales.SalesInitListFrm;
import view.sales.MemberListFrm;
import view.system.*;


/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public final class OfficeFrame extends javax.swing.JFrame {

    private List<SystemGroupAccess> menus;
    private SystemUser selectedUser;
    /**
     * Creates new form frmMainMenu
     */
    public OfficeFrame() {
       
        initComponents();
        ServicesList.MAIN_FRAME = this;
       // menus = new ArrayList<>(0);
//        menus = ServicesList.getSystemMenuService().getAll(0, 9999, null, "order by menu_id");
      
        this.setTitle("BTP Office");
        this.setExtendedState(Frame.MAXIMIZED_BOTH);
      //  ImageIcon ico = new ImageIcon(getClass().getResource("/banner_empty.png"));
        GradientPanel pnl = new GradientPanel();
        pnl.setBackground(Color.WHITE);
        pnl.setDark(true);
        pnlHeader.add(pnl);
        //lblBanner.setIcon(ico);
        
        ImageIcon ico = new ImageIcon(getClass().getResource("/Orangagon.png"));
        Image  img = ico.getImage();
        this.setIconImage(img);
        
        /*ArrayList<UIManager.LookAndFeelInfo> infos=  new ArrayList<>( Arrays.asList(     UIManager.getInstalledLookAndFeels()));
        infos.add(new UIManager.LookAndFeelInfo("Quaqua", QuaquaManager.getLookAndFeelClassName()));
        UIManager.setInstalledLookAndFeels(infos.toArray(new UIManager.LookAndFeelInfo[infos.size()])); */
        //create accordiion menu
      
    }
    
    public void execute(){
       initForm();
//       for (SystemMenu menu : menus){
//           String grpPolicy = "";
//           SystemGroupAccess grp = ServicesList.getSystemGroupAccessService().getAccessByMenuAndGroupId(menu.getMenuId(),selectedUser.getSystemGroup().getGroupId());
//           if (grp!=null) grpPolicy = grp.getPolicy();
//           if (menu)
//       }
         menus = ServicesList.getSystemGroupAccessService().getAll(0, 9999, " where policy<> '' and group_id = "+selectedUser.getSystemGroup().getGroupId(), "order by menu_id");
         AccordionMenu menu2 = new AccordionMenu();
        createMenuStructure(menu2);
        menu2.setBackground(new Color(111, 111, 111));
        menu2.setForeground(Color.white);
        menu2.setFont(new Font("tahoma", Font.PLAIN, 12));
        menu2.setMenusSize(30);
        menu2.setMenuBorders(new BevelBorder(BevelBorder.RAISED));
        setMouseAdapter(menu2);
        pnlMenu.add(menu2);
        setVisible(true);
    }

    protected void initForm(){
        lblUserInfo.setText(selectedUser.getSystemGroup().getGroupName());
        lblUserName.setText(selectedUser.getFullName());
        
    }
    public SystemUser getSelectedUser() {
        return selectedUser;
    }

    public void setSelectedUser(SystemUser selectedUser) {
        this.selectedUser = selectedUser;
    }
    
    

     private void createMenuStructure(AccordionMenu target) {
       int parentId = 0;
         for (SystemGroupAccess menu : menus){
//             SystemGroupAccess grp = ServicesList.getSystemGroupAccessService().getAccessByMenuAndGroupId(menu.getMenuId(), selectedUser.getSystemGroup().getGroupId());
//             String groupPolicy = "";
//             if (grp!=null) groupPolicy = grp.getPolicy();
             if (menu.getSystemMenu().getParentId()!=parentId){
                 parentId = menu.getSystemMenu().getParentId();
                 SystemMenu parent = ServicesList.getSystemMenuService().getSystemMenu(parentId);
                         
                 target.addNewMenu(String.valueOf(parent.getMenuId()), parent.getMenuName());
                 target.addNewLeafTo(String.valueOf(menu.getSystemMenu().getParentId()), String.valueOf(menu.getSystemMenu().getMenuId()), menu.getSystemMenu().getMenuName());
             }
             else{
                 target.addNewLeafTo(String.valueOf(menu.getSystemMenu().getParentId()), String.valueOf(menu.getSystemMenu().getMenuId()), menu.getSystemMenu().getMenuName());
             }
//             if (menu.getSystemMenu().getMenuType().equals("root")) {
//                 target.addNewMenu(String.valueOf(menu.getSystemMenu().getMenuId()), menu.getSystemMenu().getMenuName());
//             }
//             else {
////                 if ((!groupPolicy.equals("''"))&&(!groupPolicy.equals(""))){
//                     target.addNewLeafTo(String.valueOf(menu.getSystemMenu().getParentId()), String.valueOf(menu.getSystemMenu().getMenuId()), menu.getSystemMenu().getMenuName());
////                 }
//             }
         }
         
         
        
     }
     
      public void setMouseAdapter(AccordionMenu menu) {
        for (AccordionLeafItem leaf : menu.getAllLeafs()) {
            leaf.addMouseListener(getMouseAdapter());
        }
    }
     public MouseAdapter getMouseAdapter() {
        return new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                AccordionItem item = (AccordionItem) e.getSource();
             //   JOptionPane.showMessageDialog(null, "Source name: " + item.getName() + "; Source Title: " + item.getText());
                //String name = String.valueOf(SystemMenu.MENU_INVENTORY_SATUAN);
                if (item.getName().equals("exit")){
                    System.exit(1); 
                }
                else {
                    int menuId = 0;
                    try {
                        menuId = Integer.parseInt(item.getName());
                    } catch (NumberFormatException numberFormatException) {
                        
                    }
                    switch (menuId){                    
                    case SystemMenu.MENU_INVENTORY_SATUAN : 
                        UnitListFrm unitListFrm = new UnitListFrm();
                        unitListFrm.execute(false, 0);
                        createTab(item, unitListFrm.getContentPane());
                    break;
                    case SystemMenu.MENU_INVENTORY_PAKET : 
                        PackageListFrm pkgListFrm = new PackageListFrm();
                        pkgListFrm.execute(false, 0);
                        createTab(item, pkgListFrm.getContentPane());
                    break;    
                    case SystemMenu.MENU_INVENTORY_BARANG : 
                           ItemListFrm itemListFrm = new ItemListFrm();
                           itemListFrm.execute(false,0);
                            createTab(item, itemListFrm.getContentPane());
                    break;
                     case SystemMenu.MENU_INVENTORY_PRINCIPAL : 
                           PrincipalListFrm principalListFrm = new PrincipalListFrm();
                           principalListFrm.execute(false,0);
                            createTab(item, principalListFrm.getContentPane());
                    break;    
                      case SystemMenu.MENU_INVENTORY_HADIAH : 
                           HadiahListFrm hadiahListFrm = new HadiahListFrm();
                           hadiahListFrm.execute(false,0);
                            createTab(item, hadiahListFrm.getContentPane());
                    break;  
                      case SystemMenu.MENU_INVENTORY_JENIS_BARANG : 
                           DeptListFrm deptListFrm = new DeptListFrm();
                           deptListFrm.execute(false,0);
                            createTab(item, deptListFrm.getContentPane());
                    break;     
                    case SystemMenu.MENU_INVENTORY_STOK_OPNAME : 
                           AdjListFrm adjListFrm = new AdjListFrm();
                           adjListFrm.execute(false,0);
                            createTab(item, adjListFrm.getContentPane());
                    break;         
                    case SystemMenu.MENU_PURCHASE_SUPPLIER : 
                           SupplierListFrm supplierListFrm = new SupplierListFrm();
                           supplierListFrm.execute(false,0);
                           createTab(item, supplierListFrm.getContentPane());
                    break;
                        
                    case SystemMenu.MENU_PURCHASE_MAIN_SUPPLIER : //main supplier 
                        ItemSupplierFrm itemSupplierFrm = new ItemSupplierFrm();
                        itemSupplierFrm.execute(false,0);
                        createTab(item, itemSupplierFrm.getContentPane());
                    break;
                        
                    case SystemMenu.MENU_PURCHASE_DIVISI_PO : //divisi PO DivisiOrderFrm
                        DivisiOrderFrm divisiOrderFrm = new DivisiOrderFrm();
                        divisiOrderFrm.execute(false,0);
                        createTab(item, divisiOrderFrm.getContentPane());
                    break;
                        
                    case SystemMenu.MENU_PURCHASE_HPP : 
                            ItemHppFrm itemHppFrm = new ItemHppFrm();
                            itemHppFrm.execute(false,0);
                            createTab(item, itemHppFrm.getContentPane());
                    break;   
                        
                    case SystemMenu.MENU_PURCHASE_COPY_HARGA : 
                            CopyHargaFrm copyHargaFrm = new CopyHargaFrm();
                            copyHargaFrm.execute(false,0);
                            createTab(item, copyHargaFrm.getContentPane());
                    break;    
                        
                    case SystemMenu.MENU_PURCHASE_HARGA_JUAL : 
                            ItemPriceFrm itemPriceFrm = new ItemPriceFrm();
                            itemPriceFrm.execute(false,0);
                            createTab(item, itemPriceFrm.getContentPane());
                    break;        
                        
                     case SystemMenu.MENU_PURCHASE_PO : //purchase order
                            OrderListFrm orderFrm = new OrderListFrm();
                            orderFrm.execute(false,0);
                            createTab(item, orderFrm.getContentPane());
                    break;        
                        
                        
                    case SystemMenu.MENU_SALES_MEMBER : 
                           MemberListFrm memberListFrm = new MemberListFrm();
                           memberListFrm.execute(false,0);
                            createTab(item, memberListFrm.getContentPane());
                    break;    
                        
                    case SystemMenu.MENU_SYSTEM_PENGGUNA : 
                           UserListFrm userListFrm = new UserListFrm();
                           userListFrm.execute(false,0);
                            createTab(item, userListFrm.getContentPane());
                    break;
                    case SystemMenu.MENU_SYSTEM_KELOMPOK_PENGGUNA : 
                           GroupListFrm groupListFrm = new GroupListFrm();
                           groupListFrm.execute(false,0);
                            createTab(item, groupListFrm.getContentPane());
                    break;     
                     case SystemMenu.MENU_SYSTEM_HAK_PENGGUNA : 
                           GroupAccessFrm groupAccessFrm = new GroupAccessFrm();
                           groupAccessFrm.execute(false);
                            createTab(item, groupAccessFrm.getContentPane());
                    break;     
                     case SystemMenu.MENU_SYSTEM_PERUSAHAAN :
                         CompanyFrm companyFrm = new CompanyFrm();
                         companyFrm.execute(false, 1);
                         createTab(item, companyFrm.getContentPane());
                     break;
                         
                     case SystemMenu.MENU_DEVELOPMENT_PROMO :
                         PromoListFrm promoListFrm = new PromoListFrm();
                         promoListFrm.execute(false,0);
                         createTab(item, promoListFrm.getContentPane());
                     break;    
                         
                    case SystemMenu.MENU_SALES_INIT :
                         SalesInitListFrm salesInitListFrm = new SalesInitListFrm();
                         salesInitListFrm.execute(false,0);
                         createTab(item, salesInitListFrm.getContentPane());
                     break;    
                     case SystemMenu.MENU_REPORT_INVENTORY :
                         ReportPoolFrm reportPoolFrm = new ReportPoolFrm();
                         reportPoolFrm.execute("inventory",false);
                         createTab(item, reportPoolFrm.getContentPane());
                     break;    
                     case SystemMenu.MENU_REPORT_PEMBELIAN :
                         ReportPoolFrm reportPoolFrm2 = new ReportPoolFrm();
                         reportPoolFrm2.execute("purchase",false);
                         createTab(item, reportPoolFrm2.getContentPane());
                     break;    
                     case SystemMenu.MENU_REPORT_PENJUALAN :
                         ReportPoolFrm reportPoolFrm3 = new ReportPoolFrm();
                         reportPoolFrm3.execute("sales",false);
                         createTab(item, reportPoolFrm3.getContentPane());
                     break;        
                     case SystemMenu.MENU_REPORT_DEVELOPMENT :
                         ReportPoolFrm reportPoolFrm4 = new ReportPoolFrm();
                         reportPoolFrm4.execute("development",false);
                         createTab(item, reportPoolFrm4.getContentPane());
                     break;    
                                 
                    default : JOptionPane.showMessageDialog(null, "Underconstruction");break;
                    }
                }
                
                //message.setText();
            }
        };
    }
     
     public void createTab(String title, Component frame){
         if (this.isExistTab(title)) {
             return;
         }
        if (frame==null) {
             tabMain.add(title, new JPanel());
         }
        else {
             tabMain.add(title,frame);
         }     
        int idx = tabMain.getTabCount()-1;
        tabMain.setSelectedIndex(idx);
        
       JPanel pnlTab = new JPanel(new GridBagLayout());
       pnlTab.setOpaque(false);
       JLabel lblLitle = new JLabel(title+" ");
       JButton btnClose = new JButton("x");
       ImageIcon ico = new ImageIcon(getClass().getResource("/no.png"));
        //Image  img = ico.getImage();
       JLabel lblClose = new JLabel(ico) ;//new ImageIcon("/images/no.png")
       lblClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
       GridBagConstraints gbc = new GridBagConstraints();
       gbc.gridx = 0;
       gbc.gridy = 0;
       gbc.weightx = 1;
       pnlTab.add(lblLitle,gbc);
       gbc.gridx++;
       gbc.gridx+=10;
       gbc.weightx = 1;
       pnlTab.add(lblClose,gbc);
       tabMain.setTabComponentAt(idx, pnlTab);
       
       lblClose.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                
                Component selected = tabMain.getSelectedComponent();
                if (selected!=null){
                    tabMain.remove(selected);
                }
            }
       });
       btnClose.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Component selected = tabMain.getSelectedComponent();
                if (selected!=null){
                    tabMain.remove(selected);
                }
            }
        } ); 
         
     }
     
     private void createTab(AccordionItem item,Component frame){
         if (this.isExistTab(item.getText())) {
             return;
         }
        if (frame==null) {
             tabMain.add(item.getText(), new JPanel());
         }
        else {
             tabMain.add(item.getText(),frame);
         }     
        int idx = tabMain.getTabCount()-1;
        tabMain.setSelectedIndex(idx);
        
       JPanel pnlTab = new JPanel(new GridBagLayout());
       pnlTab.setOpaque(false);
       JLabel lblLitle = new JLabel(item.getText()+" ");
       JButton btnClose = new JButton("x");
       ImageIcon ico = new ImageIcon(getClass().getResource("/no.png"));
        //Image  img = ico.getImage();
       JLabel lblClose = new JLabel(ico) ;//new ImageIcon("/images/no.png")
       lblClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
       GridBagConstraints gbc = new GridBagConstraints();
       gbc.gridx = 0;
       gbc.gridy = 0;
       gbc.weightx = 1;
       pnlTab.add(lblLitle,gbc);
       gbc.gridx++;
       gbc.gridx+=10;
       gbc.weightx = 1;
       pnlTab.add(lblClose,gbc);
       tabMain.setTabComponentAt(idx, pnlTab);
       
       lblClose.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                
                Component selected = tabMain.getSelectedComponent();
                if (selected!=null){
                    tabMain.remove(selected);
                }
            }
       });
       btnClose.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Component selected = tabMain.getSelectedComponent();
                if (selected!=null){
                    tabMain.remove(selected);
                }
            }
        } ); 
         
    }
      
      
      private boolean isExistTab(String id){
          boolean rs = false;
          for (int i=0;i<tabMain.getTabCount();i++){
              
              if (tabMain.getTitleAt(i).equals(id)){
                  tabMain.setSelectedIndex(i);
                  return true;
              }
          }
          return rs;
      }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblBanner = new javax.swing.JLabel();
        popUpThemes = new javax.swing.JPopupMenu();
        themesQuaqua = new javax.swing.JMenuItem();
        popUpUser = new javax.swing.JPopupMenu();
        popChangePasswd = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        themesMetal = new javax.swing.JMenuItem();
        themesMotif = new javax.swing.JMenuItem();
        themesNimbus = new javax.swing.JMenuItem();
        themesWindows = new javax.swing.JMenuItem();
        themesWindowsClassic = new javax.swing.JMenuItem();
        popLogout = new javax.swing.JMenuItem();
        pnlContent = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        tabMain = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        pnlMenu = new javax.swing.JPanel();
        pnlHeader = new javax.swing.JPanel();
        lblUserName = new javax.swing.JLabel();
        pnlFooter = new javax.swing.JPanel();
        lblTimeInfo = new javax.swing.JLabel();
        lblUserInfo = new javax.swing.JLabel();
        pnlThemes = new javax.swing.JPanel();
        jProgressBar1 = new javax.swing.JProgressBar();

        themesQuaqua.setText("Quaqua");
        themesQuaqua.setToolTipText("");
        themesQuaqua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeThemes(evt);
            }
        });
        popUpThemes.add(themesQuaqua);

        popChangePasswd.setText("Ubah Password");
        popChangePasswd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                popChangePasswdActionPerformed(evt);
            }
        });
        popUpUser.add(popChangePasswd);

        jMenu1.setText("Ubah Tema");

        themesMetal.setText("Metal");
        themesMetal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeThemes(evt);
            }
        });
        jMenu1.add(themesMetal);

        themesMotif.setText("CDE/Motif");
        themesMotif.setToolTipText("");
        themesMotif.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeThemes(evt);
            }
        });
        jMenu1.add(themesMotif);

        themesNimbus.setText("Nimbus");
        themesNimbus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeThemes(evt);
            }
        });
        jMenu1.add(themesNimbus);

        themesWindows.setText("Windows");
        themesWindows.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeThemes(evt);
            }
        });
        jMenu1.add(themesWindows);

        themesWindowsClassic.setText("Windows Classic");
        themesWindowsClassic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeThemes(evt);
            }
        });
        jMenu1.add(themesWindowsClassic);

        popUpUser.add(jMenu1);

        popLogout.setText("Log Off");
        popLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                popLogoutActionPerformed(evt);
            }
        });
        popUpUser.add(popLogout);

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jSplitPane1.setDividerLocation(200);
        jSplitPane1.setOneTouchExpandable(true);
        jSplitPane1.setRightComponent(tabMain);

        jPanel1.setLayout(new java.awt.GridLayout(1, 1, 30, 0));

        pnlMenu.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        pnlMenu.setLayout(new javax.swing.BoxLayout(pnlMenu, javax.swing.BoxLayout.LINE_AXIS));
        jPanel1.add(pnlMenu);

        jSplitPane1.setLeftComponent(jPanel1);

        javax.swing.GroupLayout pnlContentLayout = new javax.swing.GroupLayout(pnlContent);
        pnlContent.setLayout(pnlContentLayout);
        pnlContentLayout.setHorizontalGroup(
            pnlContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        pnlContentLayout.setVerticalGroup(
            pnlContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
        );

        getContentPane().add(pnlContent, java.awt.BorderLayout.CENTER);

        pnlHeader.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlHeader.setPreferredSize(new java.awt.Dimension(400, 55));

        lblUserName.setBackground(new java.awt.Color(51, 255, 0));
        lblUserName.setText("jLabel1");
        lblUserName.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        lblUserName.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblUserNameMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout pnlHeaderLayout = new javax.swing.GroupLayout(pnlHeader);
        pnlHeader.setLayout(pnlHeaderLayout);
        pnlHeaderLayout.setHorizontalGroup(
            pnlHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlHeaderLayout.createSequentialGroup()
                .addGap(0, 274, Short.MAX_VALUE)
                .addComponent(lblUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pnlHeaderLayout.setVerticalGroup(
            pnlHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlHeaderLayout.createSequentialGroup()
                .addContainerGap(26, Short.MAX_VALUE)
                .addComponent(lblUserName)
                .addContainerGap())
        );

        getContentPane().add(pnlHeader, java.awt.BorderLayout.PAGE_START);

        pnlFooter.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlFooter.setPreferredSize(new java.awt.Dimension(400, 20));
        pnlFooter.setLayout(new javax.swing.BoxLayout(pnlFooter, javax.swing.BoxLayout.LINE_AXIS));

        lblTimeInfo.setText("lblTimeInfo");
        lblTimeInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblTimeInfo.setFocusable(false);
        lblTimeInfo.setMinimumSize(new java.awt.Dimension(100, 14));
        pnlFooter.add(lblTimeInfo);

        lblUserInfo.setText("pnlUserInfo");
        lblUserInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblUserInfo.setFocusable(false);
        lblUserInfo.setMinimumSize(new java.awt.Dimension(100, 14));
        pnlFooter.add(lblUserInfo);

        pnlThemes.setToolTipText("");
        pnlThemes.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pnlThemesMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout pnlThemesLayout = new javax.swing.GroupLayout(pnlThemes);
        pnlThemes.setLayout(pnlThemesLayout);
        pnlThemesLayout.setHorizontalGroup(
            pnlThemesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 268, Short.MAX_VALUE)
        );
        pnlThemesLayout.setVerticalGroup(
            pnlThemesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 16, Short.MAX_VALUE)
        );

        pnlFooter.add(pnlThemes);

        jProgressBar1.setPreferredSize(new java.awt.Dimension(10, 19));
        pnlFooter.add(jProgressBar1);

        getContentPane().add(pnlFooter, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void pnlThemesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlThemesMouseClicked
        // TODO add your handling code here:
        if (evt.getButton() == MouseEvent.BUTTON3){
            popUpThemes.show((Component)evt.getSource(), evt.getX(), evt.getY());
        }
    }//GEN-LAST:event_pnlThemesMouseClicked

    private void changeThemes(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeThemes
        // TODO add your handling code here:
        String themesName = evt.getActionCommand();
         try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if (themesName.equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                     SwingUtilities.updateComponentTreeUI(this);
                    //this.pack();
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OfficeFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_changeThemes

    
    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
          if (JOptionPane.showConfirmDialog(this, "Are you sure want to exit?","Confirmation",JOptionPane.YES_NO_OPTION)==0) {
            System.exit(1);
        }
         // else this.setVisible(true);
    }//GEN-LAST:event_formWindowClosing

    private void lblUserNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblUserNameMouseClicked
        // TODO add your handling code here:
         if (evt.getButton() == MouseEvent.BUTTON1){
            popUpUser.show((Component)evt.getSource(), evt.getX(), evt.getY());
        }
    }//GEN-LAST:event_lblUserNameMouseClicked

    private void popChangePasswdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_popChangePasswdActionPerformed
        // TODO add your handling code here:
        UserChangePwdFrm frm = new UserChangePwdFrm(this, true);
        frm.execute(0);
    }//GEN-LAST:event_popChangePasswdActionPerformed

    private void popLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_popLogoutActionPerformed
        // TODO add your handling code here:
     //   Office frm = new Office();
        this.dispose();
        Office.main(null);
        
    }//GEN-LAST:event_popLogoutActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(frmMainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(frmMainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(frmMainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(frmMainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new OfficeFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JLabel lblBanner;
    private javax.swing.JLabel lblTimeInfo;
    private javax.swing.JLabel lblUserInfo;
    private javax.swing.JLabel lblUserName;
    private javax.swing.JPanel pnlContent;
    private javax.swing.JPanel pnlFooter;
    private javax.swing.JPanel pnlHeader;
    private javax.swing.JPanel pnlMenu;
    private javax.swing.JPanel pnlThemes;
    private javax.swing.JMenuItem popChangePasswd;
    private javax.swing.JMenuItem popLogout;
    private javax.swing.JPopupMenu popUpThemes;
    private javax.swing.JPopupMenu popUpUser;
    private javax.swing.JTabbedPane tabMain;
    private javax.swing.JMenuItem themesMetal;
    private javax.swing.JMenuItem themesMotif;
    private javax.swing.JMenuItem themesNimbus;
    private javax.swing.JMenuItem themesQuaqua;
    private javax.swing.JMenuItem themesWindows;
    private javax.swing.JMenuItem themesWindowsClassic;
    // End of variables declaration//GEN-END:variables
}
